package com.lab.jumper;

import android.annotation.TargetApi;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.SparseArray;

import com.lab.logtrack.AppLog;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by ak
 * Bundle包装器,用来提供对原始、默认、拷贝Bundle的操作
 */
public class BundleWrapper {

    private Bundle mDefaultBundle;
    private Bundle mOriginBundle;
    private String mDataTag;

    public BundleWrapper(Bundle bundle) throws BundleException {
        if (null == bundle)
            throw new BundleException("the bundle pass to CustomBundle must not be null!");
        this.mDefaultBundle = bundle;
        this.mDataTag = bundle.getString(BundleCenter.DATA_TAG);
        this.mOriginBundle = BundleCenter.getInstance().getBundle(mDataTag);
    }

    public Object get(String key) {
        try {
            return get(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public boolean getBoolean(String key) {
        return getBoolean(key, false);
    }

    public boolean getBoolean(String key, boolean defaultValue) {
        try {
            return getBoolean(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public byte getByte(String key) {
        return getByte(key, (byte) 0);
    }

    public Byte getByte(String key, byte defaultValue) {
        try {
            return getByte(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public char getChar(String key) {
        return getChar(key, (char) 0);
    }

    public char getChar(String key, char defaultValue) {
        try {
            return getChar(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public short getShort(String key) {
        return getShort(key, (short) 0);
    }

    public short getShort(String key, short defaultValue) {
        try {
            return getShort(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public int getInt(String key) {
        return getInt(key, 0);
    }

    public int getInt(String key, int defaultValue) {
        try {
            return getInt(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public long getLong(String key) {
        return getLong(key, 0L);
    }

    public long getLong(String key, long defaultValue) {
        try {
            return getLong(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public float getFloat(String key) {
        return getFloat(key, 0.0f);
    }

    public float getFloat(String key, float defaultValue) {
        try {
            return getFloat(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public double getDouble(String key) {
        return getDouble(key, 0.0);
    }

    public double getDouble(String key, double defaultValue) {
        try {
            return getDouble(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public String getString(String key) {
        return getString(key, null);
    }

    public String getString(String key, String defaultValue) {
        try {
            return getString(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public CharSequence getCharSequence(String key) {
        return getCharSequence(key, null);
    }

    public CharSequence getCharSequence(String key, CharSequence defaultValue) {
        try {
            return getCharSequence(BundleType.DEFAULT, key, defaultValue);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return defaultValue;
    }

    public Bundle getBundle(String key) {
        try {
            return getBundle(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public <T extends Parcelable> T getParcelable(String key) {
        try {
            return getParcelable(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public Parcelable[] getParcelableArray(String key) {
        try {
            return getParcelableArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public <T extends Parcelable> ArrayList<T> getParcelableArrayList(String key) {
        try {
            return getParcelableArrayList(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(String key) {
        try {
            return getSparseParcelableArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public Serializable getSerializable(String key) {
        try {
            return getSerializable(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public ArrayList<Integer> getIntegerArrayList(String key) {
        try {
            return getIntegerArrayList(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public ArrayList<String> getStringArrayList(String key) {
        try {
            return getStringArrayList(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public ArrayList<CharSequence> getCharSequenceArrayList(String key) {
        try {
            return getCharSequenceArrayList(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public boolean[] getBooleanArray(String key) {
        try {
            return getBooleanArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public byte[] getByteArray(String key) {
        try {
            return getByteArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public short[] getShortArray(String key) {
        try {
            return getShortArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public char[] getCharArray(String key) {
        try {
            return getCharArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public int[] getIntArray(String key) {
        try {
            return getIntArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public long[] getLongArray(String key) {
        try {
            return getLongArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public float[] getFloatArray(String key) {
        try {
            return getFloatArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public double[] getDoubleArray(String key) {
        try {
            return getDoubleArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public String[] getStringArray(String key) {
        try {
            return getStringArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public CharSequence[] getCharSequenceArray(String key) {
        try {
            return getCharSequenceArray(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    public IBinder getBinder(String key) {
        try {
            return getBinder(BundleType.DEFAULT, key);
        } catch (BundleException e) {
            AppLog.w(e.getMessage());
        }
        return null;
    }

    // *******************************************************************

    public Object get(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.get(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.get(key));
        } else {
            return mDefaultBundle.get(key);
        }
    }

    public boolean getBoolean(BundleType type, String key) throws BundleException {
        return getBoolean(type, key, false);
    }

    public boolean getBoolean(BundleType type, String key, boolean defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getBoolean(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getBoolean(key, defaultValue));
        } else {
            return mDefaultBundle.getBoolean(key, defaultValue);
        }
    }

    public byte getByte(BundleType type, String key) throws BundleException {
        return getByte(type, key, (byte) 0);
    }

    public Byte getByte(BundleType type, String key, byte defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getByte(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getByte(key, defaultValue));
        } else {
            return mDefaultBundle.getByte(key, defaultValue);
        }
    }

    public char getChar(BundleType type, String key) throws BundleException {
        return getChar(type, key, (char) 0);
    }

    public char getChar(BundleType type, String key, char defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getChar(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getChar(key, defaultValue));
        } else {
            return mDefaultBundle.getChar(key, defaultValue);
        }
    }

    public short getShort(BundleType type, String key) throws BundleException {
        return getShort(type, key, (short) 0);
    }

    public short getShort(BundleType type, String key, short defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getShort(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getShort(key, defaultValue));
        } else {
            return mDefaultBundle.getShort(key, defaultValue);
        }
    }

    public int getInt(BundleType type, String key) throws BundleException {
        return getInt(type, key, 0);
    }

    public int getInt(BundleType type, String key, int defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getInt(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getInt(key, defaultValue));
        } else {
            return mDefaultBundle.getInt(key, defaultValue);
        }
    }

    public long getLong(BundleType type, String key) throws BundleException {
        return getLong(type, key, 0L);
    }

    public long getLong(BundleType type, String key, long defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getLong(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getLong(key, defaultValue));
        } else {
            return mDefaultBundle.getLong(key, defaultValue);
        }
    }

    public float getFloat(BundleType type, String key) throws BundleException {
        return getFloat(type, key, 0.0f);
    }

    public float getFloat(BundleType type, String key, float defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getFloat(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getFloat(key, defaultValue));
        } else {
            return mDefaultBundle.getFloat(key, defaultValue);
        }
    }

    public double getDouble(BundleType type, String key) throws BundleException {
        return getDouble(type, key, 0.0);
    }

    public double getDouble(BundleType type, String key, double defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getDouble(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getDouble(key, defaultValue));
        } else {
            return mDefaultBundle.getDouble(key, defaultValue);
        }
    }

    public String getString(BundleType type, String key) throws BundleException {
        return getString(type, key, null);
    }

    @TargetApi(12)
    public String getString(BundleType type, String key, String defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getString(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getString(key, defaultValue));
        } else {
            return mDefaultBundle.getString(key, defaultValue);
        }
    }

    public CharSequence getCharSequence(BundleType type, String key) throws BundleException {
        return getCharSequence(type, key, null);
    }

    @TargetApi(12)
    public CharSequence getCharSequence(BundleType type, String key, CharSequence defaultValue) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getCharSequence(key, defaultValue);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getCharSequence(key, defaultValue));
        } else {
            return mDefaultBundle.getCharSequence(key, defaultValue);
        }
    }

    public Bundle getBundle(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getBundle(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getBundle(key));
        } else {
            return mDefaultBundle.getBundle(key);
        }
    }

    public <T extends Parcelable> T getParcelable(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getParcelable(key);
        } else if (type == BundleType.CLONE) {
            return (T) cloneObject(mDefaultBundle.getParcelable(key));
        } else {
            return mDefaultBundle.getParcelable(key);
        }
    }

    public Parcelable[] getParcelableArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getParcelableArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getParcelableArray(key));
        } else {
            return mDefaultBundle.getParcelableArray(key);
        }
    }

    public <T extends Parcelable> ArrayList<T> getParcelableArrayList(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getParcelableArrayList(key);
        } else if (type == BundleType.CLONE) {
            return (ArrayList<T>) cloneObject(mDefaultBundle.getParcelableArrayList(key));
        } else {
            return mDefaultBundle.getParcelableArrayList(key);
        }
    }

    public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getSparseParcelableArray(key);
        } else if (type == BundleType.CLONE) {
            return (SparseArray<T>) cloneObject(mDefaultBundle.getSparseParcelableArray(key));
        } else {
            return mDefaultBundle.getSparseParcelableArray(key);
        }
    }

    public Serializable getSerializable(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getSerializable(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getSerializable(key));
        } else {
            return mDefaultBundle.getSerializable(key);
        }
    }

    public ArrayList<Integer> getIntegerArrayList(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getIntegerArrayList(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getIntegerArrayList(key));
        } else {
            return mDefaultBundle.getIntegerArrayList(key);
        }
    }

    public ArrayList<String> getStringArrayList(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getStringArrayList(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getStringArrayList(key));
        } else {
            return mDefaultBundle.getStringArrayList(key);
        }
    }

    public ArrayList<CharSequence> getCharSequenceArrayList(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getCharSequenceArrayList(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getCharSequenceArrayList(key));
        } else {
            return mDefaultBundle.getCharSequenceArrayList(key);
        }
    }

    public boolean[] getBooleanArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getBooleanArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getBooleanArray(key));
        } else {
            return mDefaultBundle.getBooleanArray(key);
        }
    }

    public byte[] getByteArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getByteArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getByteArray(key));
        } else {
            return mDefaultBundle.getByteArray(key);
        }
    }

    public short[] getShortArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getShortArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getShortArray(key));
        } else {
            return mDefaultBundle.getShortArray(key);
        }
    }

    public char[] getCharArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getCharArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getCharArray(key));
        } else {
            return mDefaultBundle.getCharArray(key);
        }
    }

    public int[] getIntArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getIntArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getIntArray(key));
        } else {
            return mDefaultBundle.getIntArray(key);
        }
    }

    public long[] getLongArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getLongArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getLongArray(key));
        } else {
            return mDefaultBundle.getLongArray(key);
        }
    }

    public float[] getFloatArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getFloatArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getFloatArray(key));
        } else {
            return mDefaultBundle.getFloatArray(key);
        }
    }

    public double[] getDoubleArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getDoubleArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getDoubleArray(key));
        } else {
            return mDefaultBundle.getDoubleArray(key);
        }
    }

    public String[] getStringArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getStringArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getStringArray(key));
        } else {
            return mDefaultBundle.getStringArray(key);
        }
    }

    public CharSequence[] getCharSequenceArray(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getCharSequenceArray(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getCharSequenceArray(key));
        } else {
            return mDefaultBundle.getCharSequenceArray(key);
        }
    }

    @TargetApi(18)
    public IBinder getBinder(BundleType type, String key) throws BundleException {
        if (type == BundleType.ORIGIN) {
            if (null == mOriginBundle) throw new BundleException("the origin bundle not exist!");
            return mOriginBundle.getBinder(key);
        } else if (type == BundleType.CLONE) {
            return cloneObject(mDefaultBundle.getBinder(key));
        } else {
            return mDefaultBundle.getBinder(key);
        }
    }

    //**********************************************************************

    private <T> T cloneObject(T originObj) {
        T cloneObj = null;

        // 方式1:深拷贝实现
        // 目前存在问题：关于无参构造方法缺失、内部类对象等问题
//        try {
//            cloneObj = (T) DeepCloneUtil.cloneObject(originObj);
//        } catch (IllegalAccessException e) {
//            e.printStackTrace();
//        } catch (InstantiationException e) {
//            e.printStackTrace();
//        }

        // 方式2:Json解析构造对象
        // 参与拷贝类的强制约束,必须提供默认无参构造函数
        //TODO clone object
//        cloneObj = CopyUtil.copy(originObj);
        return cloneObj;
    }

    /**
     * 获取默认Bundle
     *
     * @return
     */
    public Bundle getDefaultBundle() {
        return mDefaultBundle;
    }

    /**
     * 获取原始Bundle
     *
     * @return
     */
    public Bundle getOriginBundle() {
        return mOriginBundle;
    }

    /**
     * 回收,上层在BundleWrapper调用完毕后,调用此函数将原始Bundle清除
     */
    public void recycle() {
        BundleCenter.getInstance().removeBundle(mDataTag);
        mOriginBundle = null;
    }

    /**
     * Bundle类型
     */
    public enum BundleType {
        ORIGIN, CLONE, DEFAULT;
    }

    public class BundleException extends Exception {
        public BundleException(String detailMessage) {
            super(detailMessage);
        }
    }

}
